#ifndef __THREAD_H__
#define __THREAD_H__
#include<pthread.h>
#include<stdbool.h>
#include"common.h"
#include"stack.h"

//任务队列
typedef struct task_s{
    int netFd;
    struct task_s *next;
}task_t;

typedef struct taskQueue_s{
    task_t *front;
    task_t *rear;
    int queuesize;

}taskQueue_t;
//线程进入退出队列
int taskEnqueue(taskQueue_t *pTaskQueue,int netFd);
int taskDequeue(taskQueue_t *pTaskQueue);

//线程池结构体
typedef struct threadPool_s{
    pthread_t *pidArr;
    taskQueue_t taskQueue;
    int threadNum;
    char username[20];
    bool destory_flag;
    pthread_mutex_t mutex;
    pthread_cond_t cond;
}threadPool_t;


//线程池初始化
int threadPoolInit(threadPool_t *pthreadPool,int threadNum);

//创建子线程并阻塞等待客户端连接
void makeWorker(threadPool_t *threadPool);   

//线程任务函数指针
void *threadFunc(void* arg);

//线程清理解锁
void cleanFunc(void *pArgs);

//线程具体执行行为

void Handlevent(int sockFd,threadPool_t* threadpool);






#endif